﻿using Core.Combat.FlyerObj;
using UnityEngine;

namespace Core.Combat.CoreModule
{
    public class BulletEffectCoreModule : BulletCoreModuleBase
    {
        public BulletEffectCoreModule(Bullet obj) : base(obj)
        {
        }
        
        public override void OnBulletHit(Collider2D collider)
        {
            if (BaseBullet.CanHit(collider))
            {
                Debug.Log("击中物体造成伤害");
            }
            if (CanStopBullet())
                BaseBullet.Stop();
        }

        private bool CanStopBullet()
        {
            return BaseBullet.BulletBehaviourCoreModule.reboundCount <= 1
                   && BaseBullet.BulletBehaviourCoreModule.penetrateCount <= 0
                   && BaseBullet.BulletBehaviourCoreModule.splitCount <= 0;
        }
    }
}